package com.yuqing.sentimentapp.workspace.duty.adapter;

import android.content.Context;
import android.widget.TextView;

import com.linkface.common.adaper.CommonRecycleAdapter;
import com.linkface.common.adaper.CommonViewHolder;
import com.yuqing.sentimentapp.R;
import com.yuqing.sentimentapp.workspace.duty.entity.DutyReportResult;

import java.util.List;

/**
 * Created by shenhe on 2020/4/4.
 */
public class ToDutyAdapter extends CommonRecycleAdapter<DutyReportResult.DataBean.ReportsBean> {

    private OnItemClickListener onItemClickListener;

    public ToDutyAdapter(Context context, List<DutyReportResult.DataBean.ReportsBean> dataList, int layoutId) {
        super(context, dataList, layoutId);
    }

    @Override
    public void bindData(CommonViewHolder holder, DutyReportResult.DataBean.ReportsBean data) {
        ((TextView) holder.getView(R.id.tv_name)).setText(data.getDeptName());

        holder.itemView.setOnClickListener(v -> {
            if (onItemClickListener != null) {
                onItemClickListener.onItemClick(data);
            }
        });
    }

    public void setOnItemClickListener(OnItemClickListener listener) {
        onItemClickListener = listener;
    }

    public interface OnItemClickListener {
        void onItemClick(DutyReportResult.DataBean.ReportsBean data);
    }
}
